"""The SettingsPanel module contains the SettingsPanel class, which builds the GUI for the Settings tab"""

import wx

class SettingsPanel(wx.Panel):
    def __init__(self, parent, id, plgen, settings):
        self.plgen = plgen
        self.settings = settings

        wx.Panel.__init__(self, parent, wx.ID_ANY)

        self.deftext = wx.StaticText(self, -1, "Default startup list:", wx.Point(10,1))
        self.defbox = wx.TextCtrl(self, 20, self.settings["defaultList"], wx.Point(10,20), wx.Size(340,-1))
        self.defButton = wx.Button(self, -1, "Browse...", pos=(350, 20))
        self.Bind(wx.EVT_BUTTON, self.defBrowse, self.defButton)

        self.filetext = wx.StaticText(self, -1, "Load/Save current list:", wx.Point(10,50))
        self.filebox = wx.TextCtrl(self, 20, "", wx.Point(10,70), wx.Size(340,-1))
        self.loadButton = wx.Button(self, -1, "Load", pos=(350, 70))
        self.Bind(wx.EVT_BUTTON, self.load, self.loadButton)
        self.saveButton = wx.Button(self, -1, "Load", pos=(350, 70))
        self.Bind(wx.EVT_BUTTON, self.save, self.saveButton)

    def defBrowse(self, event):
        self.plgen.setDefaultStartupList(self.defbox.GetValue())

    def load(self):
        self.plgen.load(self.filebox.GetValue())

    def save(self):
        self.plgen.save(self.filebox.GetValue())